﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Windows.Data;

namespace ProjManagSolution
{
    public class ItemsCollection
    {

    }

    public class Task: MyTask
    {
        private string m_AssignedMember = string.Empty;

        [Display(Name = "Assigned Member")]
        public string AssignedMember
        {
            get { return this.m_AssignedMember; }
            set
            {
                if (value != this.m_AssignedMember)
                {
                    this.m_AssignedMember = value;
                }
            }
        }
    }

    public class MyTask
    {
        private string m_TaskID = string.Empty;
        private string m_TaskName = string.Empty;
        private string m_PhaseName = string.Empty;
        private DateTime m_StartDate = DateTime.Today;
        private DateTime m_Deadline = DateTime.Today;
        private string m_Priority = string.Empty;
        private bool m_Complete = false;

        // Data for undoing canceled edits.
        private Task temp_Task = null;
        private bool m_Editing = false;

        //Public properties.
        [Display(AutoGenerateField = false)]
        public string TaskID
        {
            get { return this.m_TaskID; }
            set
            {
                if (value != this.m_TaskID)
                {
                    this.m_TaskID = value;

                }
            }
        }

        [Display(Name = "Phase Name")]
        public string PhaseName
        {
            get { return this.m_PhaseName; }
            set
            {
                if (value != this.m_PhaseName)
                {
                    this.m_PhaseName = value;

                }
            }
        }

        [Display(Name = "Task Name")]
        public string TaskName
        {
            get { return this.m_TaskName; }
            set
            {
                if (value != this.m_TaskName)
                {
                    this.m_TaskName = value;

                }
            }
        }

        [Display(Name = "Start Date")]
        public DateTime StartDate
        {
            get { return this.m_StartDate; }
            set
            {
                if (value != this.m_StartDate)
                {
                    this.m_StartDate = value;

                }
            }
        }

        [Display(Name = "Deadline")]
        public DateTime Deadline
        {
            get { return this.m_Deadline; }
            set
            {
                if (value != this.m_Deadline)
                {
                    this.m_Deadline = value;

                }
            }
        }

        [Display(Name = "Priority")]
        public string Priority
        {
            get { return this.m_Priority; }
            set
            {
                if (value != this.m_Priority)
                {
                    this.m_Priority = value;

                }
            }
        }

        [Display(Name = "Complete")]
        public bool Complete
        {
            get { return this.m_Complete; }
            set
            {
                if (value != this.m_Complete)
                {
                    this.m_Complete = value;

                }
            }
        }

        // Implement INotifyPropertyChanged interface.
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        // Implement IEditableObject interface.
        public void BeginEdit()
        {
            if (m_Editing == false)
            {
                temp_Task = this.MemberwiseClone() as Task;
                m_Editing = true;
            }
        }

        public void CancelEdit()
        {
            if (m_Editing == true)
            {
                this.m_Complete = temp_Task.Complete;
                this.m_Deadline = temp_Task.Deadline;
                this.m_PhaseName = temp_Task.PhaseName;
                this.m_Priority = temp_Task.Priority;
                this.m_StartDate = temp_Task.StartDate;
                this.m_TaskName = temp_Task.TaskName;

                m_Editing = false;
            }
        }

        public void EndEdit()
        {
            if (m_Editing == true)
            {
                temp_Task = null;
                m_Editing = false;
            }
        }


    }

    public class Project
    {
        private string m_ID;
        private string m_Name;
        private string m_Manager;
        private DateTime m_StartDate;
        private string m_Description;

        [Display(AutoGenerateField = false)]
        public string ID
        {
            get { return this.m_ID; }
            set
            {
                if (value != this.m_ID)
                    this.m_ID = value;
            }
        }

        [Display(Name = "Project Name")]
        public string Name
        {
            get { return this.m_Name; }
            set 
            {
                if (value != this.m_Name)
                    this.m_Name = value;
            }
        }
        
        [Display(Name= "Project Manager")]
        public string Manager
        {
            get { return this.m_Manager; }
            set 
            {
                if (value != this.m_Manager)
                    this.m_Manager = value;
            }
        }

        [Display(Name="Start Date", AutoGenerateField = false)]
        public DateTime StartDate
        {
            get { return this.m_StartDate; }
            set 
            {
                if (value != this.m_StartDate)
                    this.m_StartDate = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string Description
        {
            get { return this.m_Description; }
            set 
            {
                if (value != this.m_Description)
                    this.m_Description = value;
            }
        }
    }

    public class User
    {
        protected string m_ID;
        protected string m_Email;
        protected string m_FirstName;
        protected string m_LastName;
        protected string m_FullName;
        protected DateTime m_Birthday;
        protected string m_Sex;
        protected string m_Address;
        protected string m_PhoneNumber;

        public User(string ID, string email,
            string firstName,
            string lastName,
            DateTime birthday,
            string sex,
            string address,
            string phoneNumber)
        {
            m_ID = ID;
            m_Email = email;
            m_FirstName = firstName;
            m_LastName = lastName;

            if (m_FirstName == "N/A" && m_LastName == "N/A")
                m_FullName = "N/A";
            else if (m_FirstName == "N/A" && m_LastName != "N/A")
                m_FullName = m_FirstName;
            else if (m_FirstName != "N/A" && m_LastName == "N/A")
                m_FullName = m_LastName;
            else
                m_FullName = m_FirstName + " " + m_LastName;

            m_Birthday = birthday;
            m_Sex = sex;
            m_Address = address;
            m_PhoneNumber = phoneNumber;
        }

        public User()
        {
            m_ID = string.Empty;
            m_Address = string.Empty;
            m_Birthday = DateTime.Today;
            m_Email = string.Empty;
            m_FirstName = string.Empty;
            m_FullName = string.Empty;
            m_LastName = string.Empty;
            m_PhoneNumber = string.Empty;
            m_Sex = string.Empty;
        }

        [Display(AutoGenerateField = false)]
        public string ID
        {
            get { return this.m_ID; }
            set
            {
                if (value != this.m_ID)
                    this.m_ID = value;
            }
        }

        [Display(Order = 1)]
        public string Email
        {
            get { return this.m_Email; }
            set
            {
                if (value != this.m_Email)
                    this.m_Email = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string FirstName
        {
            get { return this.m_FirstName; }
            set
            {
                if (value != this.m_FirstName)
                    this.m_FirstName = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string LastName
        {
            get { return this.m_LastName; }
            set
            {
                if (value != this.m_LastName)
                    this.m_LastName = value;
            }
        }

        [Display(Name = "Full Name")]
        public string FullName
        {
            get { return this.m_FullName; }
            set
            {
                if (value != this.m_FullName)
                    this.m_FullName = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public DateTime Birthday
        {
            get { return this.m_Birthday; }
            set
            {
                if (value != this.m_Birthday)
                    this.m_Birthday = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string Sex
        {
            get { return this.m_Sex; }
            set
            {
                if (value != this.m_Sex)
                    this.m_Sex = value;
            }
        }

        public string Address
        {
            get { return this.m_Address; }
            set
            {
                if (value != this.m_Address)
                    this.m_Address = value;
            }
        }

        [Display(Name = "Phone Number")]
        public string PhoneNumber
        {
            get { return this.m_PhoneNumber; }
            set
            {
                if (value != this.m_PhoneNumber)
                    this.m_PhoneNumber = value;
            }
        }

        public void MergeName()
        {
            if (m_FirstName == "N/A" && m_LastName == "N/A")
                m_FullName = "N/A";
            else if (m_FirstName == "N/A" && m_LastName != "N/A")
                m_FullName = m_FirstName;
            else if (m_FirstName != "N/A" && m_LastName == "N/A")
                m_FullName = m_LastName;
            else
                m_FullName = m_FirstName + " " + m_LastName;
        }
    }

    public class Member: User
    {
        private string m_Role;

        public Member(string ID, string email,
            string firstName,
            string lastName,
            string role,
            DateTime birthday,
            string sex,
            string address,
            string phoneNumber)
        {
            m_ID = ID;
            m_Email = email;
            m_FirstName = firstName;
            m_LastName = lastName;
            m_Role = role;

            if (m_FirstName == "N/A" && m_LastName == "N/A")
                m_FullName = "N/A";
            else if (m_FirstName == "N/A" && m_LastName != "N/A")
                m_FullName = m_FirstName;
            else if (m_FirstName != "N/A" && m_LastName == "N/A")
                m_FullName = m_LastName;
            else
                m_FullName = m_FirstName + " " + m_LastName;

            m_Birthday = birthday;
            m_Sex = sex;
            m_Address = address;
            m_PhoneNumber = phoneNumber;
        }

        public Member()
        { 
        
        }

        [Display(AutoGenerateField = true, Order = 2)]
        public string Role
        {
            get { return this.m_Role; }
            set
            {
                if (value != this.m_Role)
                    this.m_Role = value;
            }
        }
    }

    public class OwnedProjectItem
    {
        [Display(AutoGenerateField = false)]
        public string Id { get; set; }
        public string Name { get; set; }
        public DateTime StartDate { get; set; }
        public string Description { get; set; }
    }

    public class InvolvedProjectItem
    {
        [Display(AutoGenerateField = false)]
        public string Id { get; set; }
        public string Name { get; set; }
        public DateTime StartDate { get; set; }
        public string Role { get; set; }
        public string Description { get; set; }
    }

    public class Milestone
    {
        private string m_ID;
        private string m_Name;
        private DateTime m_StartDate;
        private DateTime m_EndDate;
        private string m_Description;

        [Display(AutoGenerateField=false)]
        public string ID
        {
            get { return m_ID; }
            set
            {
                if (m_ID != value)
                    m_ID = value;
            }
        }

        [Display(Name = "Milestone Name")]
        public string Name
        {
            get { return m_Name; }
            set
            {
                if (m_Name != value)
                    m_Name = value;
            }
        }

        [Display(Name = "Start Date")]
        public DateTime StartDate
        {
            get { return m_StartDate; }
            set
            {
                if (m_StartDate != value)
                    m_StartDate = value;
            }
        }

        [Display(Name = "End Date")]
        public DateTime EndDate
        {
            get { return m_EndDate; }
            set
            {
                if (m_EndDate != value)
                    m_EndDate = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string Description
        {
            get { return m_Description; }
            set
            {
                if (m_Description != value)
                    m_Description = value;
            }
        }
    }

    public class Phase
    {
        private string m_ID;
        private string m_Name;
        private string m_MilestoneID;
        private string m_Milestone;
        private DateTime m_StartDate;
        private DateTime m_EndDate;
        private string m_Description;

        [Display(AutoGenerateField = false)]
        public string ID
        {
            get { return m_ID; }
            set
            {
                if (m_ID != value)
                    m_ID = value;
            }
        }

        [Display(Name = "Phase Name")]
        public string Name
        {
            get { return m_Name; }
            set
            {
                if (m_Name != value)
                    m_Name = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string MilestoneID
        {
            get { return m_MilestoneID; }
            set
            {
                if (m_MilestoneID != value)
                    m_MilestoneID = value;
            }
        }

        [Display(Name = "Milestone", AutoGenerateField = false)]
        public string Milestone
        {
            get { return m_Milestone; }
            set
            {
                if (m_Milestone != value)
                    m_Milestone = value;
            }
        }

        [Display(Name = "Start Date")]
        public DateTime StartDate
        {
            get { return m_StartDate; }
            set
            {
                if (m_StartDate != value)
                    m_StartDate = value;
            }
        }

        [Display(Name = "End Date")]
        public DateTime EndDate
        {
            get { return m_EndDate; }
            set
            {
                if (m_EndDate != value)
                    m_EndDate = value;
            }
        }

        [Display(AutoGenerateField = false)]
        public string Description
        {
            get { return m_Description; }
            set
            {
                if (m_Description != value)
                    m_Description = value;
            }
        }
    }

    public partial class Documentation
    {

        private DateTime m_UploadDate;
        private int m_ID;
        private string m_Name;
        private string m_Status;
        private string m_Url;

        //private int folder_idField;

        //private int uploader_idField;

        //private ProjManagSolution.pmMyWebService.user userField;

        [Display(AutoGenerateField = false)]
        public int ID
        {
            get { return this.m_ID; }
            set
            {
                if (this.m_ID != value)
                    this.m_ID = value;
            }
        }

        [Display(Name = "Document Name")]
        public string Name
        {
            get { return this.m_Name; }
            set
            {
                if (this.m_Name != value)
                    this.m_Name = value;
            }
        }

        [Display(Name = "Upload Date")]
        public DateTime UploadDate
        {
            get { return this.m_UploadDate; }
            set
            {
                if (this.m_UploadDate != value)
                    this.m_UploadDate = value;
            }
        }

        [Display(Name = "Document Status")]
        public string Status
        {
            get { return this.m_Status; }
            set
            {
                if (this.m_Status != value)
                    this.m_Status = value;
            }
        }

        [Display(Name = "URL")]
        public string Url
        {
            get { return this.m_Url; }
            set
            {
                if (this.m_Url != value)
                    this.m_Url = value;
            }
        }
    }
}
